<?php require_once('Connections/sepolwan_connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE memberdb SET aktif=%s WHERE id=%s",
                       GetSQLValueString($_POST['aktif'], "text"),
                       GetSQLValueString($_POST['id'], "int"));

  mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
  $Result1 = mysql_query($updateSQL, $sepolwan_connect) or die(mysql_error());

  $updateGoTo = "login.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_aktif = "-1";
if (isset($_GET['key'])) {
  $colname_aktif = $_GET['key'];
}
mysql_select_db($database_sepolwan_connect, $sepolwan_connect);
$query_aktif = sprintf("SELECT * FROM memberdb WHERE aktif = %s", GetSQLValueString($colname_aktif, "text"));
$aktif = mysql_query($query_aktif, $sepolwan_connect) or die(mysql_error());
$row_aktif = mysql_fetch_assoc($aktif);
$totalRows_aktif = mysql_num_rows($aktif);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Aktifasi Akun</title>
<link href="gaya/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php if ($totalRows_aktif > 0) { // Show if recordset not empty ?>
  <table width="300" style="border:1px #000099 solid" align="center" cellpadding="20" cellspacing="0">
    <tr>
      <td align="center" bgcolor="#FFFFFF"><p><img src="images/logo2.png" width="188" height="57" /></p>
        <p>Selamat Datang <?php echo $row_aktif['full_name']; ?> , silahkan aktifasi akun anda dengan cara klik button di bawah    </p>
        <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
          <input type="submit" value="Aktifasi Akun" />
          <input type="hidden" name="id" value="<?php echo $row_aktif['id']; ?>" />
          <input type="hidden" name="aktif" value="ya" />
          <input type="hidden" name="MM_update" value="form1" />
          <input type="hidden" name="id" value="<?php echo $row_aktif['id']; ?>" />
      </form></td>
    </tr>
  </table>
  <?php } // Show if recordset not empty ?>
</body>
</html>
<?php
mysql_free_result($aktif);
?>
